/**   
 * @Title: ZhiFuBaoOrderIDCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.recharg 
 * @Description: (获取支付宝单号接口) 
 * @author: Billy Qigs@500wan.com   
 * @date: 2011-11-1 下午5:28:10  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.recharg;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.DistributionChannels;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: ZhiFuBaoOrderIDCommunicater
 * @Description: (获取支付宝单号接口)
 * @author: Billy Qigs@500wan.com
 * @date: 2011-11-1 下午5:28:10
 * 
 */
public class ZhiFuBaoOrderIDCommunicater extends ServerCommunicater {

	private String msgServer = "";

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String str) {
		this.msgServer = str;
	}

	public boolean isGetOrderIDSucceed(Context context, String money) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException, NameNotFoundException {
		boolean isSucceed = false;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

		if (UserInfo.getUserInfo().getUserSession() == null || UserInfo.getUserInfo().getUserSession().length() < 0) {
			return false;
		} else if (UserInfo.getUserInfo().getUserName() == null || UserInfo.getUserInfo().getUserName().length() < 0) {
			return false;
		} else if (UserInfo.getUserInfo().getUserPwd() == null || UserInfo.getUserInfo().getUserPwd().length() < 0) {
			return false;
		} else {
			list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_ZHIFUBAO_GET_ORDER_ID));
			list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
			list.add(mapItem(Key.KEY_USERNAME, UserInfo.getUserInfo().getUserName()));
			list.add(mapItem(Key.KEY_PASSWORD, UserInfo.getUserInfo().getUserPwd()));
			list.add(mapItem(Key.KEY_VERSION, context.getPackageManager().getPackageInfo(Config.APP_PACKAGE_INFO, 0).versionName));
			list.add(mapItem(Key.KEY_CHANNEL, DistributionChannels.QUDAO));
			list.add(mapItem(Key.KEY_MONEY, money));

			super.getServerResponse(list, true);
			setMsgServer(super.getServerMsg());
			if (super.getState() == 100) {
				isSucceed = true;
			}

			return isSucceed;
		}
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
